<template>
  <div class="questionlist">
    <a-card :bordered="false" style="border-radius:8px;" :bodyStyle="{padding:'13px 26px 23px 22px'}">
      <a-list item-layout="horizontal" :data-source="knowList" :pagination="pagination">
        <a-list-item slot="renderItem" slot-scope="item">
          <div class="flex row_bet col_center" style="width: 100%">
            <div class="line-1 ago" @click="godetails(item)"> {{ item.q }}</div>
            <div class="float_right">
              <a-space>
                <span>{{ item.view_num }} 浏览  {{ item.a_num }} 回答</span>
                <span>{{ item.q_user }}</span>
                <span>{{ item.q_time }}</span>
              </a-space>
            </div>
          </div>
        </a-list-item>
        <div slot="header">
          <div class="title">问题列表</div>
        </div>
      </a-list>
    </a-card>
  </div>
</template>
<script>
  import { getProblemList } from '@/api/knowledgeApi'

  export default {
    name: 'Questionlist',
    data () {
      return {
        type: 1,
        knowList: [
          // {
          //   a_num: 60,
          //   id: 156,
          //   q: '分享一下你给客服沟通的第一句话术是啥',
          //   q_time: '2019-10-25 12:35:59',
          //   q_user: '刘素真',
          //   view_num: 1129
          // },
        ],
        pagination: {
          onChange: page => {
            console.log(page, this.knowList)
            this.getProblemList(page, 14, this.type)
          },
          total: 0,
          pageSize: 14
        }
      }
    },
    computed: {},
    created () {
      console.log(this.$route.query.type)
      if (this.$route.query) {
        this.type = this.$route.query.type
        this.getProblemList(1, 14, this.type)
      }
    },
    mounted () {

    },
    methods: {
      godetails (row) {
        this.$store.dispatch('setRowsname', row)
        this.$router.push({
          path: '/knowledgecase/index/questionDetails'
        })
      },
      getProblemList (page, pagesize, type, sort) {
        getProblemList({
          page: page,
          pagesize: pagesize,
          type: type,
          sort: sort
        }).then(res => {
          console.log(res)
          if (res.code === 200) {
            this.knowList = res.data.data
            this.pagination.total = res.data.count
          }
        }).catch(err => {
          console.log(err)
        })
      }
    }
  }
</script>
<style lang='less' scoped>
  .questionlist {
    width: 1140px;
    margin: 0 auto;

    .title {
      font-weight: 600;
      color: #333333;
    }
    .ago{
      color: #2396F9;
      cursor: pointer;
    }
  }
</style>
